<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>NEW</title>
</head>
<body>
    <canvas width="800" height="600"></canvas>
    <script>
        const W = 800, H = 600;
        const canvas = document.querySelector('canvas');
        const ctx = canvas.getContext('2d');

        canvas.width = ctx.width = W;
        canvas.height = ctx.height = H;

        ctx.fillStyle = 'red';
        ctx.fillRect(0, 0, 200, 100);

        ctx.translate(100, 50);
        ctx.rotate(Math.PI/4);

        ctx.fillStyle = 'blue';
        ctx.fillRect(-100, -50, 200, 100);

        ctx.setTransform(1, 0, 0, 1, 0, 0);

    </script>
</body>
</html>